import React, { useState } from 'react';
import { withRouter } from 'react-router-dom';
import '@/styles/intell.less';
import header from '../../assets/titleStatic.png';
import {Tabs, Upload, Button, Input, message} from 'antd';
import newest from '../../assets/zuixin.gif';
import { evidenceTop } from '@/utils/api';
import {connect} from "react-redux";

const { Search } = Input;

interface IState {
  list: any,
    pageIndex: number,
    year:string,
    departList:string
}

interface IProps {
  login: any,
  register: any,
  history: any,
  match:any
}
class IntellCenter extends React.Component<IProps, IState> {
  constructor(props: any) {
    super(props);
    this.state = {
      list: [],
      pageIndex: 1,
      year:"",
      departList:""
    }

      sessionStorage.setItem("path", this.props.match.path)

     console.log(this.props)
    evidenceTop(
        {
            page: this.state.pageIndex,
            data: this.state.year,
            department: this.state.departList
        }
    )
        .then((res: any) => {
          console.log(res)
          this.setState({
            list: res.data,
          });
        })
        .catch((error: any) => {
          message.error(error);
        })
  }


  render () {
    console.log(this.state)
    const { list } = this.state
    return (
        <div className="intell">
          <div className="header">
            <img src={ header } alt="" />
          </div>

          <div className="contentItem">
            <div>

              <Search
                  placeholder="标题/作者"
                  allowClear
                  enterButton="检索"
                  size="large"
                  // onSearch={onSearch}
                  style={{ width: 700, margin: '30px auto' }}
              />
            </div>
            <div>
              <div>
                <div className="newWestStyle">
                  <img src={ newest } alt="" />
                </div>
                {
                  list.map((item: any,index: any)=>{
                      return(
                          <div className="bagItem" key={item.idea_id}>
                            <div>标题：<a href="">{item.title}</a></div>
                            <div>ID: {item.title_hash}</div>
                            <div>简介： {item.introduce}</div>
                            <div>机构：中国科学院心理研究所</div>
                            <div>注册时间： {item.created}</div>
                            <div>更新时间： {item.updated}</div>
                          </div>
                      )
                    })
                }
              </div>
            </div>
          </div>
          <div className="footerIn">
            @基于区块链的科学论文证据链框架研究
          </div>
        </div>
    )
  }
}


export default withRouter(connect((state: any) => state.user, {  evidenceTop })(IntellCenter))



